<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <include file="./Application/Admin/View/block/amap_header.php" />
    <link href="__PUBLIC__/css/Content/index.css" rel="stylesheet" type="text/css" />
    <link href="__PUBLIC__/css/easyui_extend_yearandmonth.css" rel="stylesheet" type="text/css" />
    <script src="__PUBLIC__/js/easyui_extend_yearandmonth.js"></script>
    <style>
        #dg{
            height: 100%;;
        }
        #center .panel{
            float: left;
        }
    </style>
    <script>
        $(function(){
            $('#csdtStationTree').tree({
                method: 'get',
                checkbox : false,
                lines: true,
                url : '/Manage/AdminCsdt/get_csdt_station_tree',
                checkbox:true,
            });

        });

        function export_xls(){
            if(getChecked()==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的调蓄池',showType:'slide'});
                return;
            }
            $('#yy_window').window('open');
        }

        function bz_xls(){
            var s = getChecked();
            if(s==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的调蓄池',showType:'slide'});
                return;
            }
            $('#zb_window').window('open');
        }

        function check_check(){
            var s = getChecked();
            if(s==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的调蓄池',showType:'slide'});
                return false;
            }
            return true;
        }

        function getChecked(){
            var nodes = $('#csdtStationTree').tree('getChecked');
            var s = '';
            for(var i=0; i<nodes.length; i++){
                if (!$('#csdtStationTree').tree('isLeaf', nodes[i].target)||isNaN(nodes[i].id)) {
                    continue;
                }
                if (s != '') s += ',';
                s += nodes[i].id;
            }
            return s;
        }


    </script>
</block>
<block name="bdoy">
    <body>
    <input type="hidden" id="dsfg" name="dsfg" value="dsfg"/>
    <input type="hidden" id="csdtstation_id" name="csdtstation_id"/>
    <div class="easyui-layout" style="width:100%;height: 500px;"  fit="true">
        <div data-options="region:'west',split:true" title="调蓄池" style="width:240px;">

            <ul id="csdtStationTree" class="easyui-tree"></ul>
        </div>
        <div data-options="region:'center'" id="center">
            <?php if(I('get.type')==1){ ?>
                <div class="easyui-panel" title="泵机运行记录" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">起始日期：</td>
                            <td><input id="pump_start_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">结束日期：</td>
                            <td><input id="pump_end_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_pump_date()" class="easyui-linkbutton" style="width:120px">按日期排序导出</a>
                            <a href="javascript:split_pump()" class="easyui-linkbutton" style="width:120px">按设备排序导出</a>
                        </td>
                    </table>
                </div>
                <div class="easyui-panel" title="格栅机运行记录" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">起始日期：</td>
                            <td><input id="mac_start_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">结束日期：</td>
                            <td><input id="mac_end_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_machine()" class="easyui-linkbutton" style="width:120px">导出</a>
                        </td>
                    </table>
                </div>
                <div class="easyui-panel" title="水电表记录" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">起始日期：</td>
                            <td><input id="waterele_start_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">结束日期：</td>
                            <td><input id="waterele_end_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_waterele()" class="easyui-linkbutton" style="width:120px">导出</a>
                        </td>
                    </table>
                </div>
                <div class="easyui-panel" title="闸门运行记录" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">起始日期：</td>
                            <td><input id="gate_start_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">结束日期：</td>
                            <td><input id="gate_end_date" class="easyui-datetimebox textbox" editable="false"></td>
                        </tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_gate()" class="easyui-linkbutton" style="width:120px">导出</a>
                        </td>
                    </table>
                </div>
                <div class="easyui-panel" title="考勤表(单个)" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">起始日期：</td>
                            <td><input id="ch_start_date" class="easyui-datebox textbox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">结束日期：</td>
                            <td><input id="ch_end_date" class="easyui-datebox textbox" editable="false"></td>
                        </tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_reglog()" class="easyui-linkbutton" style="width:120px">导出</a>
                        </td>
                    </table>
                </div>
                <div class="easyui-panel" title="考勤表(汇总)" style="width:300px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">起始日期：</td>
                            <td><input id="ch_start_date_all" class="easyui-datebox textbox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">结束日期：</td>
                            <td><input id="ch_end_date_all" class="easyui-datebox textbox" editable="false"></td>
                        </tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_reglog_all()" class="easyui-linkbutton" style="width:120px">导出</a>
                        </td>
                    </table>
                </div>
                <div class="easyui-panel" title="月报表" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">选择开始日期：</td>
                            <td><input id="txc_month_start_date" class="easyui-datetimebox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">选择结束日期：</td>
                            <td><input id="txc_month_end_date" class="easyui-datetimebox" editable="false"></td>
                        </tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_month()" class="easyui-linkbutton" style="width:120px">导出</a>
                        </td>
                    </table>
                </div>
            <?php } else {?>
                <div class="easyui-panel" title="调蓄池运行情况周报表" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td>起始日期:<input id="yy_start_date_week" class="easyui-datebox" editable="false" style="width: 100px;"></td>
                        </tr>
                        <tr>
                            <td>截止日期:<input id="yy_end_date_week" class="easyui-datebox" editable="false" style="width: 100px;"></td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2">
                                <a href="javascript:split_yy_csdt_week()" class="easyui-linkbutton" style="width:200px">导出</a>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="easyui-panel" title="调蓄池运行汇总表" style="width:350px;height:200px;padding:10px;float: left;">
                    <table>
                        <tr>
                            <td width="100" align="center">选择开始日期：</td>
                            <td><input id="yy_start_month" class="easyui-datebox" editable="false"></td>
                        </tr>
                        <tr>
                            <td width="100" align="center">选择结束日期：</td>
                            <td><input id="yy_end_month" class="easyui-datebox" editable="false"></td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2">
                                <a href="javascript:manage_exp_csdt_month_total()" class="easyui-linkbutton" style="width:200px">调蓄池月报表总表</a>
                            </td>
                        </tr>
                    </table>
                </div>
            <?php }?>
        </div>

    </div>
    <div id="gtx_window" class="easyui-window" closed="true" title="导出月报表" data-options="modal:true" style="width:300px;height:150px;padding:0px;overflow: hidden;">
        <form id="form">
            <table class="form-table">
                <tr>
                    <td width="100" align="center">选择日期：</td>
                    <td><input id="start_date_m" class="easyui-datebox textbox" required data-options="validType:'md[\'10/11/2012\']',prompt:'{:LANG('pls_slet')}{:LANG('start_date')}'"></td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <a href="javascript:split_month()" class="easyui-linkbutton" style="width:120px">{:LANG('export')}</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        $(function(){
            $('.month').combobox('yearandmonth')
        });


        function split_pump(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            export_pump(temp_ids);
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_pump(temp_ids[i]);
//            }
        }

        function export_pump(id){
            var start = $('#pump_start_date').datetimebox('getValue');
            var end = $('#pump_end_date').datetimebox('getValue');
            var url = '/Manage/AdminCsdtPump/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_pump_date(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            export_pump_date(temp_ids);
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_pump(temp_ids[i]);
//            }
        }

        function export_pump_date(id){
            var start = $('#pump_start_date').datetimebox('getValue');
            var end = $('#pump_end_date').datetimebox('getValue');
            var url = '/Manage/AdminCsdtPump/export_record_by_date?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_machine(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            export_machine(temp_ids);
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_machine(temp_ids[i]);
//            }
        }

        function export_machine(id){
            var start = $('#mac_start_date').datetimebox('getValue');
            var end = $('#mac_end_date').datetimebox('getValue');
            var url = '/Manage/AdminCsdtMachine/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_waterele(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            export_waterele(temp_ids);
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_waterele(temp_ids[i]);
//            }
        }

        function export_waterele(id){
            var start = $('#waterele_start_date').datetimebox('getValue');
            var end = $('#waterele_end_date').datetimebox('getValue');
            var url = '/Manage/AdminCsdtWaterele/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_gate(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            export_gate(temp_ids);
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_gate(temp_ids[i]);
//            }
        }

        function export_gate(id){
            var start = $('#gate_start_date').datetimebox('getValue');
            var end = $('#gate_end_date').datetimebox('getValue');
            var url = '/Manage/AdminCsdtGate/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_reglog(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            export_reglog(temp_ids);
        }

        function export_reglog(id){
            var start = $('#ch_start_date').datetimebox('getValue');
            var end = $('#ch_end_date').datetimebox('getValue');
            var url = '/Manage/AdminMobileAdmin/export_record?pid='+id+'&start='+start+'&end='+end+'&station=csdt';
            window.open(url);
        }

        function split_reglog_all(){
            var start = $('#ch_start_date_all').datetimebox('getValue');
            var end = $('#ch_end_date_all').datetimebox('getValue');
            var url = '/Manage/AdminMobileAdmin/export_record_all?start='+start+'&end='+end+'&station=csdt';
            window.open(url);
        }

        function split_month(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            temp_ids = temp_ids.split(",");
            for(var i=0;i<temp_ids.length;i++){
                export_month(temp_ids[i]);
            }
        }

        function export_month(id){
            var start = $('#txc_month_start_date').datetimebox('getValue');
            var end = $('#txc_month_end_date').datetimebox('getValue');
            var url = '/Manage/OnlyExport/csdt_month?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }

        function split_yy_csdt_week(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_yy_week2(temp_ids[i]);
//            }
            export_yy_csdt_week(temp_ids);
        }

        function export_yy_csdt_week(ids){
            var start = $('#yy_start_date_week').datetimebox('getValue');
            var end = $('#yy_end_date_week').datetimebox('getValue');
            var url = '/Manage/OnlyExport/csdt_week?ids='+ids+'&start='+start+'&end='+end;
            window.open(url);
        }

        function manage_exp_csdt_month_total(){
            var start = $('#yy_start_month').combobox('getValue');
            var end = $('#yy_end_month').combobox('getValue');
            var url = '/Manage/OnlyExport/csdt_month_total?start='+start+'&end='+end;
            window.open(url);
        }
    </script>
</block>
